package com.leonzx.base.service;

import com.google.gson.Gson;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * 业务层的基类
 *
 * Created by 梁亮 on 2018/3/27
 */
public class BaseService {
    protected final Logger logger = getLogger();
    protected Gson gson = new Gson();

    @Autowired
    protected SqlSessionFactory sqlSessionFactory;

    public SqlSession getSqlSession() {
        return sqlSessionFactory.openSession();
    }


    public Logger getLogger() {
        Logger logger = LoggerFactory.getLogger(this.getClass());
        return logger;
    }
}
